<%@page language="java" contentType="text/html; charset=utf-8"%>

<%@page import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<%@page import="com.git.report.ReportModelImpl"%>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%  
String baseUrl = request.getContextPath();
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
%> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">  
<link rel="stylesheet" type="text/css" href="<%=basePath%>style/css/page.css" />  
<title>定义风险报告模版</title>
<script src="<%=baseUrl%>/script/lasheet_v0.9.js"></script>
<script src="<%=baseUrl%>/script/lajax.js"></script>
<script language="JavaScript">

function tick() {
	var hours, minutes, seconds;
	var intHours, intMinutes, intSeconds,intYear ,intMonth ,intdat ;
	var today = new Date();

	intYear = today.getFullYear();

	intMonth = today.getMonth()+1;
	intdat = today.getDate();
	intHours = today.getHours();
	intMinutes = today.getMinutes();
	intSeconds = today.getSeconds();

	if (intHours == 0) {
	hours = "00:";
	} else if (intHours < 10) { 
	hours = "0" + intHours+":";
	} else {
	hours = intHours + ":";
	}

	if (intMinutes < 10) {
	minutes = "0"+intMinutes+":";
	} else {
	minutes = intMinutes+":";
	}
	if (intSeconds < 10) {
	seconds = "0"+intSeconds+" ";
	} else {
	seconds = intSeconds+" ";
	} 
	timeString = intYear+"-"+intMonth+"-"+intdat+"  "+hours+minutes+seconds;
	//Clock.innerHTML = timeString;
	var ss = document.getElementById("inputEr");
	document.getElementById('inputTime').value=timeString;
	window.setTimeout("tick();", 1000);
	}
	 	
window.onload = tick;


</script>

<style type="text/css">

	* { padding:0; font-size:12px;  color:#444;}
	
	body { margin:5;}

	table { border-bottom: 1px solid #CCC; border-right: 1px solid #CCC; margin:5px auto;}

	td { border-top: 1px solid #CCC; border-left: 1px solid #CCC; padding-top:5px; padding-bottom:5px; padding-left:5px; height:22px; line-height:22px;}

	input[type="text"] { border: 1px solid #CCC; height:20px; background:#FFD}

	input[type="submit"] { font-size:12px; width: 70px; height:28px; margin-left:20px;}
	
	input[type="button"] { font-size:12px; width: 70px; height:28px; margin-left:20px;}
	
	input[type="radio"] { font-size:12px; width: 70px; height:28px; margin-left:20px;}
	input[type="reset"] { font-size:12px; width: 70px; height:28px; margin-left:20px;}
	checkbox
	input[type="checkbox"] { border: 1px solid #CCC; height:20px; background:#FFD}
	select {height:24px; border:1px solid #8ac;}

	textarea{font-size:12px; width: 190px; height:88px; margin-left:20px;background:#FFD}
	h2.title { font-weight:normal; margin-left:10px; margin-top:3px;}

	div.board { margin:5px; border:1px solid #CCC;}

</style>

<script type="text/javascript">
function selectMark(rskSubType,sessionId){
	var orgCode = document.getElementById("orgCode").value;
	if(orgCode == null || orgCode==""){
		alert("请选择使用机构");
		return;
	}
	
	var rskSub = document.getElementById(rskSubType).checked;
	
	if(rskSub == false){
		alert("请勾选风险类型");
		return;
	}
	var modelCode = document.getElementById("modelCode").value;

	var url = "<%=request.getContextPath() %>/ReportModelServlet?method=find&rskSubType="+rskSubType+"&orgCode="+orgCode+"&sessionId="+sessionId+"&modelCode="+modelCode;
	window.open(url,'_blank');
	
}

function selectReport(rskSubType,sessionId,cogfId){
	
	var orgCode = document.getElementById("orgCode").value;
	if(orgCode == null || orgCode==""){
		alert("请选择使用机构");
		return;
	}
	
	var rskSub = document.getElementById(rskSubType).checked;
	
	if(rskSub == false){
		alert("请勾选风险类型");
		return;
	}
	
	var modelCode = document.getElementById("modelCode").value;

	var url = "<%=request.getContextPath() %>/ReportModelServlet?method=findReport&rskSubType="+rskSubType+"&orgCode="+orgCode+"&sessionId="+sessionId+"&cogfId="+cogfId+"&modelCode="+modelCode;
	window.open(url,'_blank');
	
}
function checkSubmit()
{
	var modelName = trim(report.modelName.value);
 
	if(modelName == ''){
		alert("请输入模板名称!");
		return false;
	}
	
}

function checkAll(name){
	
	var el = document.getElementsByTagName("input");
	var len = el.length;
	for(var i=0;i<len;i++){
		if((el[i].type=="checkbox") && (el[i].name==name)){
			el[i].checked =true;
		}
	}
	
}

function clearAll(name){
	
	var el = document.getElementsByTagName("input");
	var len = el.length;
	for(var i=0;i<len;i++){
		if((el[i].type=="checkbox") && (el[i].name==name)){
			el[i].checked =false;
		}
	}
	
}

</script>
</head>

<body>
<div class="board">
<form id="report" enctype="multipart/form-data" name="report" method="post" action="<%=request.getContextPath() %>/ReportModelServlet?method=add&release=1" onsubmit="return checkSubmit(this);">
 
 <table cellpadding="0" cellspacing="0" style="width: 70%">
 
 	<tr>
 		<td width="300px" >模版/报告编号 &nbsp;&nbsp; <input id="modelCode" type="text" name="modelCode" value="<c:out value="${modelCode}"/>" readonly="readonly"/></td>
 		<td width="300px" >模版/报告名称&nbsp;&nbsp;<input id="modelName" type="text" name="modelName" /></td>
 	</tr>
 	<tr>
 		<td>创     建  人&nbsp;&nbsp;&nbsp;<input id="inputEr" disabled="disabled" type="text" name="inputEr" value="<c:out value="${user}"/>"/></td>
 		<td>创建时间&nbsp;&nbsp;<input id="inputTime" type="text" readonly="readonly" name="inputTime" value="" /></td>
 	</tr>
 	<tr>
 		<td >模版\报告  <select style="width: 220px; margin-left: 20px;" name="isReportModel" > <option value="0" >模版 </option><option value="1" selected="selected">报告 </option>  </select> </td>
 		<td >导入相关报告<input type="file" name="riskReport" size="20" maxlength="80"></td>
 	</tr>

 	
 </table>
 <p style="margin-left: 15%">风险报告构成 &nbsp;&nbsp;&nbsp;  全选 <input type="checkbox" name="isrsk" id="isrsk" onclick="if(this.checked==true) { checkAll('rskSubType'); } else { clearAll('rskSubType'); }" ></p>
		
 <table cellpadding="0" cellspacing="0" style="width: 70%">

 <tr>
		<c:forEach items="${risk}" var="ReportModelImpl">
		<c:set var="first" value="true"></c:set>
			<c:forEach items="${ReportModelImpl.listRsk}" var="rsk">
			<tr>
				<c:if test="${first}">
				<c:set var="first" value="false"/>
					<td width="260px" style="text-align: center;" rowspan="${fn:length(ReportModelImpl.listRsk)}"><c:out value="${ReportModelImpl.riskname.riskName}" /></td>
				</c:if>
				<td width="300px" style="text-align:left;padding-left: 20px"><input id="<c:out value="${rsk.rskSubType}" />" type="checkbox" name="rskSubType" value="<c:out value="${rsk.rskSubType}" />" /> <c:out value="${rsk.rskSubName}" /></td>
			</tr>
			</c:forEach>
		</c:forEach>
 </tr>
 </table>
	<table cellpadding="0" cellspacing="0" style="width: 70%">
   		<tr>
			<td colspan="2"><input type="submit" name="submit" value="保存" /></td>
			<td><input name="reset" type ="reset" value = "重置" /></td>
		</tr>
	</table>
 </form>
</div>
</body>
</html>
